<template>
    <a-card :bordered="false">
        <a-layout >
      <a-layout-sider theme="light" :style="{ overflow: 'auto', height: '60vh'}">
        <a-tree :tree-data="treeData" :replaceFields="replaceFields" @select="onSelect"/>
     </a-layout-sider>
      <a-layout-content style="background: #fff;">
        
          <a-tabs default-active-key="1" v-if="visible" @change="tabChange">
             
             <a-tab-pane key="1" tab="系统字典">
                <systemDictList ref="systemDictList"></systemDictList>
            </a-tab-pane>
            <a-tab-pane key="2" tab="应用字典">
                <dictList ref="dictList"></dictList>
            </a-tab-pane>
        
            <a-tab-pane key="3" tab="缓存字典">
                <cacheDictList ref="cacheDictList"></cacheDictList>
            </a-tab-pane>
            <a-tab-pane key="4" tab="自定义缓存字典">
                <customCacheDictList ref="customCacheDictList"></customCacheDictList>
            </a-tab-pane>
        </a-tabs>
      
        
      </a-layout-content>
  
    </a-layout>

         

    </a-card>
   
</template>
<script>
import dictList from './dictList'
import cacheDictList from './cacheDictList'
import systemDictList from './systemDictList'
import customCacheDictList from './customCacheDictList'
import {getSystemInfo} from '@/api/system'
export default {
    name:'dictTab',
    data(){
         return{
            tabPage:{'1':'systemDictList','2':'dictList','3':'cacheDictList','4':'customCacheDictList',},
            currentSystemNo:'',
            currentTab:'1',
            replaceFields:{title:'systemName',vlaue:'systemNo',key:'systemNo'},
            treeData:[],
            visible:false,
          
         }
    },
    components:{
        dictList,
        cacheDictList,
        systemDictList,
        customCacheDictList
    },
    methods:{
         //获取系统信息
        getSystemInfo(){
            let that = this;
            getSystemInfo().then(res => {
                if(res.success && res.result){
                    that.treeData = res.result
                }
            })
        },
        onSelect(selectedKeys, info){
            let that = this;
            that.visible=true;
            that.currentSystemNo = info.node.eventKey;
            that.$nextTick(() => {
              that.$refs[that.tabPage[that.currentTab]].queryBySystemNo(that.currentSystemNo)
            })
           
        },
        tabChange(key){
            let that = this;
            that.currentTab=key;
            that.$nextTick(() => {
              that.$refs[that.tabPage[that.currentTab]].queryBySystemNo(that.currentSystemNo)
            })
        }
    },
    created(){
        //加载数据
        this.getSystemInfo();
    },
}
</script>